﻿$(function () {
    var reg = /sid=(.+)/;
    var ms = location.href.match(reg);
    if (ms) {
        $("#extenCode").val(ms[1]);
    }
});

function ShowTip(obj, msg){
    
}

function ClearTip(obj) {
    phone.silbling('small').remove();
}

function OnClickGetCode() {
    var phone = $("#userPhone");
    if ((/^1[34578]\d{9}$/.test(phone.val()))) {
        var nTime = 60;
        //取消点击响应, 避免重复点击
        $("#sendCode").attr("onclick", "");
        //按钮不可用, 并进入60秒倒计时
        $("#sendCode").attr("disabled", true);

        var timeTer = setInterval(function (e) {
            --nTime;
            $("#sendCode").text("已发送! (" + nTime + " s)");
            if (0 == nTime) {
                clearInterval(timeTer);
                $("#sendCode").attr("disabled", false);
                $("#sendCode").attr("onclick", "OnClickGetCode()");
                $("#sendCode").text("获取验证码");
            }
        }, 1000);

        $.post("/PostMsg.aspx", "posttype=getcode&phoneNum=" + phone.val(), function (e) {
            if ("ok" == e) {
               
            }
            else {
                alert(e);
                $("#sendCode").attr("onclick", "OnClickGetCode()");
            }
        });
    }
    else {
        alert("输入有效手机号码");
    }
}


function checkForm() {
    var phone = $("#userPhone");
    if (!(/^1[34578]\d{9}$/.test(phone.val()))) {
        alert("输入有效手机号码");
        return false;
    }

    var phoneCheck = $("#phoneCheck");
    if (!(/^\d{6}$/.test(phoneCheck.val()))) {
        alert("输入有效验证码");
        return false;
    }

    var pas1 = $("#userPassword").val();
    var pas2 = $("#userPassword1").val();
    if (pas1 && pas2) {
        if (pas1 != pas2) {
            alert("两次输入的密码不一致, 请重新输入!");
            return false;
        }
    }
    else {
        alert("密码不能为空");
        return false;
    }

    return true;
}